<?php

/**
 * 客栈列表
 */
class listAction extends globalAction {
    private $dao;
    
    public function _initialize() {
		parent::_initialize();
        parent::_loginRequire();
        $this->dao = D('Inn');
	}
    
    public function index() {
        $innList = $this->dao
            ->field($this->dao->_map_flip)
            ->where(array(
                $this->dao->_map['menuId'] => 585,
                $this->dao->_map['uid'] => __USERID__
            ))
            ->order(array(
                $this->dao->_map['display_order'] => 'desc'
            ))
            ->select();
        
        //字段附加
        if($innList) {
            $innCount = count($innList);
            $InnCooperationDao = D('InnCooperation');
            $InnTypeDao = D('InnType');
            for($i = 0; $i < $innCount; $i++) {
                //合作方式
                $InnCooperation = $InnCooperationDao
                    ->field($InnCooperationDao->_map_flip)
                    ->where(array(
                        $InnCooperationDao->_map['menuId'] => 600,
                        $InnCooperationDao->_map['id'] => intval($innList[$i]['cooperation'])
                    ))
                    ->find();
                $innList[$i]['cooperation'] = $InnCooperation['name'];
                //客栈类别
                $InnType = $InnTypeDao
                    ->field($InnTypeDao->_map_flip)
                    ->where(array(
                        $InnTypeDao->_map['menuId'] => 606,
                        $InnTypeDao->_map['id'] => intval($innList[$i]['type'])
                    ))
                    ->find();
                $innList[$i]['type'] = $InnType['name'];
            }
        }
        $this->assign('innList', $innList);
        $this->display();
    }
}